/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import com.handeasy.entity.CommentEntity;
import com.handeasy.session.CommentSessionBean;
import com.handeasy.session.CommentState;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import javax.inject.Named;

/**
 *
 * @author Amaury
 */
@ManagedBean
@Named(value = "adminBean")
@SessionScoped
public class AdminBean implements Serializable {

    
    private String username;
    private String password;
    private boolean isConnected = false;
    private List<CommentEntity> listComm;
    
    @EJB
    CommentState commBean;
    
    /**
     * Creates a new instance of AdminBean
     */
    public AdminBean() {
    }
    
    public String login(){
        System.err.println("ADMIN LOGIN");
     if(username.equalsIgnoreCase("admin") && password.equalsIgnoreCase("mdp")){
            System.out.println("ADMIN OK");
            isConnected = true;
            return "panel.xhtml?faces-redirect=true";
        }
        System.err.println("ADMIN NNNOK");
        
        return "login";
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public List<CommentEntity> getListComm() {
        listComm = commBean.getComments();
        return listComm;
    }

    public void setListComm(List<CommentEntity> listComm) {
        this.listComm = listComm;
    }

    public boolean isIsConnected() {
        return isConnected;
    }

    public void setIsConnected(boolean isConnected) {
        this.isConnected = isConnected;
    }
    
    
    
}
